﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SectionWidthScaler : MonoBehaviour
{
    public SkinnedMeshRenderer smr;
    public Transform[] bones;
    public Mesh origin;
    public Mesh baked;
    private void Start()
    {
        origin = Instantiate(smr.sharedMesh);
    }
    [ContextMenu("Bake")]
    public void Bake()
    {
        smr.sharedMesh = origin;
        baked = new Mesh();
        baked.name = "Baked Mesh";
        smr.BakeMesh(baked);
        smr.sharedMesh = baked;
        smr.sharedMesh.bindposes = origin.bindposes;
        smr.sharedMesh.boneWeights = origin.boneWeights;
        foreach (var bone in bones)
        {
            bone.localScale = Vector3.one;
        }
    }
}
